home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-1.iso / comm / ytsg3.zip / MYERROR.C < prev    next >
Text File  |  1993-05-05  |  5KB  |  102 lines

  1. /************************************************/
  2. /* Author: G.R. Blair                           */
  3. /*         BOBBLAIR @ AUSVM1                    */
  4. /*         bobblair@bobblair.austin.ibm.com     */
  5. /*                                              */
  6. /* The following code is property of            */
  7. /* International Business Machines Corporation. */
  8. /*                                              */
  9. /* Copyright International Business Machines    */
  10. /* Corporation, 1991.  All rights reserved.     */
  11. /************************************************/
  12.  
  13.  
  14. /*------------------------------------------------------------------------*/
  15. /*                                                                        */
  16. /*  myerror                                                               */
  17. /*                                                                        */
  18. /*  Display an error message.  The format of the message is               */
  19. /*      name of this program (if filled in by the main program)           */
  20. /*      (area) - Dos or program function which detected the error         */
  21. /*      rc - numerical return code                                        */
  22. /*      (details) - information about the object involved in the error    */
  23. /*      text - a description of the error condition.                      */
  24. /*                                                                        */
  25. /*  Calling sequence:                                                     */
  26. /*      extern char *myerror_pgm_name;                                    */
  27. /*                                                                        */
  28. /*      myerror_pgm_name = "myprogram";                                   */
  29. /*      myerror(rc, area, details);                                       */
  30. /*                                                                        */
  31. /*  where                                                                 */
  32. /*      myerror_pgm_name is a pointer to a string representing the        */
  33. /*                       name of the calling program.                     */
  34. /*                                                                        */
  35. /*      rc               is the OS/2 return code (integer).               */
  36. /*                                                                        */
  37. /*      area             is a pointer to a string representing the area   */
  38. /*                       of the program or the DOS function that detected */
  39. /*                       the error.                                       */
  40. /*                                                                        */
  41. /*      details          is a pointer to a string containing additional   */
  42. /*                       information about the error, such as a file name */
  43. /*                       or, perhaps, the amount of space requested in a  */
  44. /*                       malloc.                                          */
  45. /*------------------------------------------------------------------------*/
  46.  
  47. #include <stdio.h>
  48. #define  INCL_BASE
  49. #define  INCL_NOPM
  50. #include <os2.h>
  51.  
  52. char *myerror_pgm_name = NULL;
  53.  
  54. void myerror(int rc, char *area, char *details)
  55. {
  56.    if (myerror_pgm_name != NULL)
  57.      fprintf(stderr,
  58.              "%s (%s) rc=%d (%s): ", myerror_pgm_name, area, rc, details);
  59.    else
  60.      fprintf(stderr,
  61.              "(%s) rc=%d (%s): ", area, rc, details);
  62.               /*--------------------------------------------------------------*/
  63.               /* Figure out the appropriate text based on return code.        */
  64.               /*--------------------------------------------------------------*/
  65.    switch(rc)
  66.    {
  67. //   case NO_ERROR:                printf("No error - good return code\n");
  68. //      break;
  69.    case ERROR_FILE_NOT_FOUND:    printf("File not found\n");
  70.       break;
  71.    case ERROR_NO_MORE_FILES:     printf("File not found\n");
  72.       break;
  73.    case ERROR_PATH_NOT_FOUND:    printf("Path not found \n");
  74.       break;
  75.    case ERROR_INVALID_HANDLE:    printf("Bad search handle\n");
  76.       break;
  77.    case ERROR_INVALID_DRIVE:     printf("Invalid drive specified\n");
  78.       break;
  79.    case ERROR_ACCESS_DENIED:     printf("Access denied\n");
  80.       break;
  81.    case ERROR_NOT_DOS_DISK:      printf("Invalid disk format\n");
  82.       break;
  83.    case ERROR_INVALID_PARAMETER: printf("Pgm error - parm\n");
  84.       break;
  85.    case ERROR_DRIVE_LOCKED:      printf("Cannot access disk\n");
  86.       break;
  87.    case ERROR_BUFFER_OVERFLOW:   printf("Pgm error - buffer size\n");
  88.       break;
  89.    case ERROR_NO_MORE_SEARCH_HANDLES: printf("Out of search handles\n");
  90.       break;
  91.    case ERROR_FILENAME_EXCED_RANGE: printf("File name too big\n");
  92.       break;
  93.    case ERROR_SHARING_VIOLATION: printf("Sharing violation\n");
  94.       break;
  95.    case ERROR_CURRENT_DIRECTORY: printf("Can't delete current directory\n");
  96.       break;
  97.    case ERROR_NOT_ENOUGH_MEMORY: printf("Not enough memory for malloc\n");
  98.       break;
  99.    default:                      printf("Unexpected error\n");
  100.    }
  101. }
  102.